<include file="/public/header" />
<div class="layui-fluid">
    <div class="layui-card">
        <!-- // 默认操作按钮 -->
        <div class="layui-card-header layadmin-card-header-auto ">
        <div class="layui-form">
            <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input name="title" class="layui-input" type="text" placeholder="{:__('岗位名称')}"/>
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input name="alias" class="layui-input" type="text" placeholder="{:__('岗位标识')}"/>
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input name="content" class="layui-input" type="text" placeholder="{:__('备注查询')}"/>
                </div>
            </div>
            <div class="layui-inline" >
                <!-- // 默认搜索 -->
                <button class="layui-btn icon-btn" lay-filter="formSearch" lay-submit><i class="layui-icon layui-icon-search"></i>{:__('搜索')}</button>
                <!-- // 打开添加页面 -->
                <button class="layui-btn icon-btn" lay-open="" data-title="添加岗位{:__('')}" data-area="500px" data-url="#editforms" >
                    <i class="layui-icon layui-icon-add-1"></i>{:__('添加')}
                </button>
            </div>
            </div>
        </div>   
        </div>

        <!-- // 创建数据表实例 -->
        <table id="lay-tableList" lay-filter="lay-tableList"></table>        
    </div>
</div>

<!-- // 添加编辑数据 -->
<script type="text/html" id="editforms" >
<div class="layui-fluid layui-bg-white">
    <form class="layui-form layui-form-fixed" lay-filter="editforms" >
    <input type="text" name="id" hidden="">

    <div class="layui-form-item">
        <label class="layui-form-label"><font color="red">* </font>{:__('岗位名称')}</label>
        <div class="layui-input-block">
            <input name="title" placeholder="{:__('请岗位名称')}" type="text" class="layui-input" lay-verify="required" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">{:__('岗位标识')}</label>
        <div class="layui-input-block">
            <input name="alias" placeholder="{:__('请岗位标识')}" type="text" class="layui-input"  lay-verify="required" />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">{:__('排序号')}</label>
        <div class="layui-input-block">
            <input name="sort" placeholder="{:__('默认自动生成')}" type="number" class="layui-input"   />
        </div>
    </div>    

    <div class="layui-form-item">
        <label class="layui-form-label">{:__('岗位状态')}</label>
        <div class="layui-input-block">
            <input name="status" type="radio" value="1" title="{:__('正常')}" checked/>
            <input name="status" type="radio" value="0" title="{:__('停用')}"/>
        </div>
    </div> 

    <div class="layui-form-item">
        <label class="layui-form-label">{:__('岗位备注')}</label>
        <div class="layui-input-block">
            <textarea name="content" id="content" cols="30" rows="10" style="min-height: 110px;" placeholder="{:__('请输入岗位备注')}" class="layui-textarea" 
            lay-verify="required"></textarea>
        </div>
    </div>

    <div class="layui-footer layui-form-item layui-center "  >
        <button class="layui-btn layui-btn-primary" type="button" sa-event="closePageDialog" >{:__('取消')}</button>
        <button class="layui-btn" lay-add="{:url('/system.jobs/add')}" lay-edit="{:url('/system.jobs/edit')}" lay-filter="submitPage"  lay-submit>{:__('提交')}</button>
    </div>
    </form>
</div>
</script>


<!-- // 列表工具栏 -->
<script type="text/html" id="tableBar"> 
    <a class="layui-table-text" data-title="{:__('编辑')}" data-area="500px" data-url="#editforms" lay-event="edit"  >{:__('编辑')}</a>
    <div class="layui-divider layui-divider-vertical"></div>
    <a class="layui-table-text" data-url="{:url('/system.jobs/del')}?id={{d.id}}" lay-event="del" >{:__('删除')}</a>
</script>

<include file="/public/footer" />
<script>
    layui.use(['table','soulTable'], function () {

        var table = layui.table;
        var soulTable = layui.soulTable;
        /*
         * 初始化表格
        */
        var isTable = table.render({
            elem: "#lay-tableList"
            ,url: "{:url('/system.jobs/index')}"
            ,page: true
            ,cols: [[
                {type: 'checkbox', width:50},
                {field: 'id', align: 'center',sort: true,width: 80,  title: 'ID'},
                {field: 'title', align: 'center', title: "{:__('岗位名称')}"},
                {field: 'alias', align: 'center', title: "{:__('岗位标识')}"},
                {field: 'content', align: 'center',title: "{:__('岗位备注')}"},
                {field: 'create_time', align: 'center',title: "{:__('创建时间')}"},
                {align: 'center', toolbar: '#tableBar',width: 160, title: "{:__('操作')}"},
            ]]
            ,rowDrag: {
                // 表格排序
                done: function(obj) {
                    console.log(obj)
                    // let ids = [];
                    // for (const k in obj.cache) {
                    //     ids.push(obj.cache[k].id)
                    // }
                    // $.post("/central.php/system.archives/sort.html",{
                    //     ids : ids
                    // }, function(res) {
                    //     if (res.code == 200) {
                    //         layer.msg(res.msg);
                    //     } else {
                    //         layer.error(res.msg);
                    //     }
                    // })
                }
            }
            ,done: function(res, curr, count) {
                if (!res.data || res.code === 101) {
                    $('.layui-table-page').remove();
                }

                soulTable.render(this);
            }
        })
    });

</script>
